/**
 * 
 */
package com.tvt.smsapp_demo.appconfig.reader;

import java.io.IOException;
import java.io.InputStream;

import org.simpleframework.xml.Serializer;
import org.simpleframework.xml.core.Persister;

import android.content.Context;
import android.os.Debug;

import com.tvt.smsapp_demo.appconfig.xml.AppConfigXml;

/**
 * @author MR_HIEU
 * 
 */
public class AppConfigReader {

	private static final String LOG_TAG = "AppConfigReader";

	public static AppConfigXml decodeAppConfig(Context pContext,
			String pXmlAssetPath) {

		InputStream is = null;
		try {
			is = pContext.getAssets().open(pXmlAssetPath);
		} catch (IOException e1) {
			e1.printStackTrace();
		}

		if (is != null) {

			AppConfigXml appConfig = null;

			Serializer serializer = new Persister();
			try {
				appConfig = serializer.read(AppConfigXml.class, is);
			} catch (Exception e) {
				e.printStackTrace();
			}

			return appConfig;

		} else {
			return null;
		}

	}
}
